package com.rayo.accesscontrollercopy.model.db.bean;

import com.alibaba.fastjson.JSON;
import com.litesuits.orm.db.annotation.Column;
import com.litesuits.orm.db.annotation.Table;

import java.util.Date;
import java.util.List;

/**
 * Created by yanghaojie on 16/7/27.
 */
@Table("operator_table")
public class OperatorData extends BaseModel {
    public static final String OPEROATR_ID = "operid";
    public static final String LOGIN = "login";
    public static final String PASSWORD = "password";

    private String first;

    private String last;

    @Column(OPEROATR_ID)
    private int operid;

    @Column(LOGIN)
    private String login;

    @Column(PASSWORD)
    private String password;

    //0未激活,1已激活
    private int active;

    private String authority;

    public OperatorData() {
        this.first = "";
        this.last = "";
        this.operid = 0;
        this.login = "";
        this.password = "";
        this.authority = "";
        this.editime = new Date();
        this.active=0;
    }

    public void updateData(OperatorData item) {
        this.setAuthority(item.getAuthority());
        this.setFirst(item.getFirst());
        this.setLast(item.getLast());
        this.setLogin(item.getLogin());
        this.setPassword(item.getPassword());
    }

    public int getActive() {
        return active;
    }

    public void setActive(int active) {
        this.active = active;
    }

    public String getFirst() {
        return first;
    }

    public void setFirst(String first) {
        this.first = first;
    }

    public String getLast() {
        return last;
    }

    public void setLast(String last) {
        this.last = last;
    }

    public int getOperid() {
        return operid;
    }

    public void setOperid(int operid) {
        this.operid = operid;
    }

    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getAuthority() {
        return authority;
    }

    public void setAuthority(String authority) {
        this.authority = authority;
    }

    public static List<OperatorData> formJsonStr(String data) {
        List<OperatorData> list;
        try {
            list = JSON.parseArray(data, OperatorData.class);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
        return list;
    }
}

